﻿using Reactor.Environment;
using Reactor.Messages.Events.Endpoint;
using Reactor.Messaging.Attributes;

namespace Reactor.Messaging.ServiceBus
{
    [PubSubChannel]
    public class EndpointOnlineHandler : IMessageHandler<EndpointOnline>
    {
        /// <summary>
        /// Handles the specified message by .
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="messageContext">The message context.</param>
        public void Handle(EndpointOnline message, IMessageContext messageContext)
        {
            if(Context.ServiceBus.Configuration.CurrentEndpointInputChannel.DestinationName != message.SubscriberName)
                Context.ServiceBus.Configuration.DestinationRegistry.LookupSubscriberByName(message.SubscriberName);
        }
    }
}
